package lex.mtd.ui.details;

import java.util.Hashtable;
import java.util.Map;

import javax.swing.JComponent;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;

import org.lex.net.log.Log;
import org.lex.net.log.ui.TextPaneLog;

import lex.mtd.core.utils.LogSet;

public class TabLogSet extends JTabbedPane implements LogSet
{
	private Map<String, Log> logSet = null;

	public TabLogSet()
	{
		logSet = new Hashtable<String, Log>();
	}

	@Override
	public int getLogCount()
	{
		return logSet.size();
	}

	@Override
	public Log getLog( String name )
	{
		if( null == name )
			name = "";
		Log log = logSet.get( name );
		if( null == log )
		{
			TextPaneLog tpl = new TextPaneLog();
			insertLogPane( name, new JScrollPane( tpl ) );
			log = tpl;
			logSet.put( name, log );
		}
		return log;
	}

	private void insertLogPane( String name, JComponent log )
	{
		//FIXME ����name�������ӵ�JTabbedPane
		this.addTab( name, log );
	}
}
